/**
 * 
 */
var toHomeBtn = "<a href=\"main.php\">Back</a>";
var requiredMsg = "This field is required.";
function changePasswordSubmit()
{
	var resetObj = {};
	resetObj.oldpassword = $("#regMainContainer").find( 'input[name="oldPassword"]' ).val();
	resetObj.newpassword = $("#regMainContainer").find( 'input[name="newPassword"]' ).val();
	resetObj.token = $("#regMainContainer").find( 'input[name="tokenNumber"]' ).val();
	var confirmPass = $("#regMainContainer").find( 'input[name="confirmPassword"]' ).val();

	var isReturned = false;
	if(resetObj.oldpassword == "")
	{
		isReturned = true;
		$("#newPassErrorMsg").empty().append(requiredMsg);
	}

	if(resetObj.newpassword == "")
	{
		isReturned = true;
		$("#newPassErrorMsg").empty().append(requiredMsg);
	}

	if(resetObj.confirmPass == "")
	{
		isReturned = true;
		$("#newPassErrorMsg").empty().append(requiredMsg);
	}

	if(isReturned)
		return;

	if(confirmPass == resetObj.newpassword)
	{
		showPreloader(true);
		resetObj.oldpassword = $.sha1(resetObj.oldpassword);
		resetObj.newpassword = $.sha1(resetObj.newpassword);
		
		$.post("changepassword.php", resetObj, function(data) {
			if(data == 0)
			{
				$("#resetResult").empty().append( "<b>Change password successful.</b>" );
				$("#btnChangePass").empty().append(toHomeBtn);
			}
			else
				$("#resetResult").empty().append(data);
			
	    	showPreloader(false);
	    });
	}
	else
		$("#confirmPassErrorMsg").empty().append("Confirm not match");
}